<template>
	<view class="m-bg-c">
		<view class="m-card">
			<view class="u-p-l-10 u-p-r-10">
				<u--form labelPosition="left" :labelWidth='100' :model="fromData" ref="uForm">
					<u-form-item :required="true" label="楼盘名称:" prop="properties_name">
						<view class="input u-rela">
							<u-search shape="square" searchIcon=' ' :clearabled='false' height='64' :showAction='false'
								v-model="fromData.properties_name" inputAlign='right' bgColor='#eee' placeholder='请输入'
								@change="$u.debounce(search, 500)" v-if="!loupanShow">
							</u-search>
							<u-overlay :show="loupanShow" @click="loupanShow = false,distinguish=2" zIndex='10'>
								<view class="m-bg-w default u-abso m-mg-lr boxinput" @tap.stop>
									<view class="u-m-t-20 m-mg-lr">
										<view class="u-flex u-flex-between">
											<view class="u-flex u-flex-items-center">
												楼盘名称:
											</view>
											<view class="u-m-l-20">
												<u-search shape="square" searchIcon=' ' :clearabled='false' height='64'
													:showAction='false' v-model="fromData.properties_name"
													inputAlign='right' bgColor='#eee' placeholder='请输入'
													@change="$u.debounce(search, 500)">
												</u-search>
											</view>
										</view>
										<view class="boxinput-y">
											<view v-if="loupanList.length > 0">
												<view class="u-m-t-30 u-p-b-20" v-for="(item, index) in loupanList"
													:key="index" @click="getmieng(item,index)">
													{{item.name}}
												</view>
											</view>
											<view class="u-m-t-30" v-else>暂时没有搜索到相关出租房，内当家会尽快与你联系</view>
										</view>
									</view>
								</view>
							</u-overlay>
						</view>
					</u-form-item>
					<u-form-item :required="true" label="居住楼层:" prop="floor">
						<view class="input">
							<u-search shape="square" searchIcon=' ' :clearabled='false' height='64' :showAction='false'
								v-model="fromData.floor" inputAlign='right' bgColor='#eee' placeholder='请输入'>
							</u-search>
						</view>
					</u-form-item>
					<u-form-item :required="true" label="居住房号:" prop="roomnumber">
						<view class="input">
							<u-search shape="square" searchIcon=' ' :clearabled='false' height='64' :showAction='false'
								v-model="fromData.roomnumber" inputAlign='right' bgColor='#eee' placeholder='请输入'>
							</u-search>
						</view>
					</u-form-item>
					<u-form-item :required="true" label="出租价格:" prop="price">
						<view class="u-flex u-flex-items-center">
							<u-search shape="square" searchIcon=' ' :clearabled='false' height='64' :showAction='false'
								v-model="fromData.price" inputAlign='right' bgColor='#eee' placeholder='请输入'>
							</u-search>
							<text class="u-font-25 u-m-l-20">月</text>
						</view>
					</u-form-item>
					<u-form-item :required="true" label="出租面积:" prop="area">
						<view class="v-input">
							<u-search shape="square" searchIcon=' ' :clearabled='false' height='64' :showAction='false'
								v-model="fromData.area" inputAlign='right' bgColor='#eee' placeholder='请输入'>
							</u-search>
						</view>
					</u-form-item>
					<u-form-item :required="true" label="房屋押金:" prop="paytype">
						<view class="u-flex u-flex-items-center">
							<view class="v-input" @click="shows = true">
								<u-search shape="square" searchIcon=' ' :clearabled='false' height='64'
									:showAction='false' v-model="fromData.paytype" disabled inputAlign='right'
									bgColor='#eee' placeholder='请选择'>
								</u-search>
							</view>
						</view>
					</u-form-item>

					<u-form-item :required="true" label="房屋朝向:" prop="orientation">
						<view class="u-flex u-flex-items-center">
							<view class="v-input" @click="show = true">
								<u-search shape="square" searchIcon=' ' :clearabled='false' height='64'
									:showAction='false' v-model="fromData.orientation" disabled inputAlign='right'
									bgColor='#eee' placeholder='请选择'>
								</u-search>
							</view>
							<text class="u-font-25 u-m-l-32 m-c-9">阳台朝向为主</text>
						</view>
					</u-form-item>
					<u-form-item :required="true" label="房屋户型:" prop="bedroom">
						<view class="u-flex u-flex-items-center">
							<view class="u-flex u-flex-items-center">
								<view class="boxhuxing u-flex u-flex-items-center">
									<u--input type='number' inputAlign='center' v-model="fromData.bedroom"
										placeholder=' ' border="none">
									</u--input>
								</view>
								<text class="u-font-25 u-m-l-5 m-c-9">室</text>
							</view>
							<view class="u-flex u-flex-items-center">
								<view class="boxhuxing u-flex u-flex-items-center">
									<u--input type='number' inputAlign='center' v-model="fromData.room" placeholder=' '
										border="none">
									</u--input>
								</view>
								<text class="u-font-25 u-m-l-5 m-c-9">厅</text>
							</view>
							<view class="u-flex u-flex-items-center">
								<view class="boxhuxing u-flex u-flex-items-center">
									<u--input type='number' inputAlign='center' v-model="fromData.toilet"
										placeholder=' ' border="none">
									</u--input>
								</view>
								<text class="u-font-25 u-m-l-5 m-c-9">卫</text>
							</view>
							<view class="u-flex u-flex-items-center">
								<view class="boxhuxing u-flex u-flex-items-center">
									<u--input type='number' inputAlign='center' v-model="fromData.balcony"
										placeholder=' ' border="none">
									</u--input>
								</view>
								<text class="u-font-25 u-m-l-5 m-c-9">阳台</text>
							</view>
						</view>
					</u-form-item>

					<u-form-item :required="true" label="房屋地址:" prop="province">
						<view class="u-flex u-flex-items-center u-flex-wrap">
							<view @click="pick('province')">
								<view class="boxdizhi" :class="fromData.province ? '' : 'ce1'">
									{{fromData.province || '请选择'}}
								</view>
							</view>
							<view class="u-m-l-20" @click="pick('city')">
								<view class="boxdizhi">
									<text :class="fromData.city ? '' : 'ce1'">{{fromData.city||'请选择'}}</text>
								</view>
							</view>
							<view class="u-m-l-20" @click="pick('areaname')">
								<view class="boxdizhi">
									<text :class="fromData.areaname ? '' : 'ce1'">{{fromData.areaname||'请选择'}}</text>
								</view>
							</view>
						</view>
					</u-form-item>
					<u-form-item label="房屋图片:" :required="true" prop="tupian"></u-form-item>
					<view class="u-flex u-flex-wrap">
						<view v-if="images.length > 0" class="u-m-r-20 boximg u-m-b-20" v-for="(item,index) in images"
							:key='index'>
							<view class='iconde'>
								<u-icon name='close-circle-fill' size='20' color='#dadada' @click='getde(index)'>
								</u-icon>
							</view>
							<u--image :src='item' width='95' height='95' radius='0'></u--image>
						</view>
						<view v-if="images.length < 5" class="boxup u-flex u-flex-wrap u-flex-around" @click="getup">
							<view>
								<u-icon name='photo' size='50' color='#ddd'></u-icon>
							</view>
							<view>
								<text>上传图片</text>
							</view>
						</view>
					</view>
					<view class="m-c-9 u-m-b-30 u-flex u-flex-end">至少上传5张图片</view>
					<u-form-item label="是否带装修:" :required="true">
						<view class="">
							<radio-group @change="radioChange0"
								class="u-flex u-flex-wrap u-flex-between u-flex-items-center">
								<label class="u-flex u-m-t-10 w_40" v-for="(item, index) in radiolist1"
									:key="item.name">
									<view>
										<radio :value="item.name" color='#DAAF7F' :checked="index === current0" />
									</view>
									<view>{{item.name}}</view>
								</label>
							</radio-group>
						</view>
					</u-form-item>
					<u-form-item label="房屋状态:" :required="true">
						<view>
							<radio-group @change="radioChange1"
								class="u-flex u-flex-wrap u-flex-between u-flex-items-center">
								<label class="u-flex u-m-t-10 w_40" v-for="(item, index) in radiolist2"
									:key="item.name">
									<view>
										<radio :value="item.name" color='#DAAF7F' :checked="index === current1" />
									</view>
									<view>{{item.name}}</view>
								</label>
							</radio-group>
						</view>
					</u-form-item>
					<u-form-item label="房屋性质:" :required="true">
						<view>
							<radio-group @change="radioChange2"
								class="u-flex u-flex-wrap u-flex-between u-flex-items-center">
								<label class="u-flex u-m-t-10 w_40" v-for="(item, index) in radiolist8"
									:key="item.name">
									<view>
										<radio :value="item.name" color='#DAAF7F' :checked="index === current2" />
									</view>
									<view>{{item.name}}</view>
								</label>
							</radio-group>
						</view>
					</u-form-item>
					<u-form-item label="是否有电梯:" :required="true">
						<view class="u-flex u-flex-items-center">
							<view class="v-input" @click="showa = true">
								<u-search shape="square" searchIcon=' ' disabled :clearabled='false' height='64'
									:showAction='false' v-model="fromData.elevator" inputAlign='right' bgColor='#eee'
									placeholder='请选择'>
								</u-search>
							</view>
						</view>
					</u-form-item>
					<u-form-item label="是否带家具:" :required="true">
						<view>
							<u-checkbox-group @change="radioChange3">
								<view class="u-flex u-flex-wrap u-flex-between">
									<label class="u-flex u-m-t-10 w_40" v-for="(item, index) in radiolist4"
										:key="item.name">
										<view>
											<u-checkbox size='23' shape="circle" :name="item.name" activeColor='#DAAF7F'
												:checked="item.disabled" />
										</view>
										<view>{{item.name}}</view>
									</label>
								</view>
							</u-checkbox-group>
						</view>
					</u-form-item>
					<u-form-item label="可否煮饭:" :required="true">
						<view>
							<radio-group @change="radioChange4"
								class="u-flex u-flex-wrap u-flex-between u-flex-items-center">
								<label class="u-flex u-m-t-10 w_40" v-for="(item, index) in radiolist5"
									:key="item.name">
									<view>
										<radio :value="item.name" color='#DAAF7F' :checked="index === current4" />
									</view>
									<view>{{item.name}}</view>
								</label>
							</radio-group>
						</view>
					</u-form-item>
					<u-form-item label="可否住小孩:" :required="true">
						<view>
							<radio-group @change="radioChange5"
								class="u-flex u-flex-wrap u-flex-between u-flex-items-center">
								<label class="u-flex u-m-t-10 w_40" v-for="(item, index) in radiolist6"
									:key="item.name">
									<view>
										<radio :value="item.name" color='#DAAF7F' :checked="index === current5" />
									</view>
									<view>{{item.name}}</view>
								</label>
							</radio-group>
						</view>
					</u-form-item>
					<u-form-item label="可否携宠物:" :required="true">
						<view>
							<radio-group @change="radioChange6"
								class="u-flex u-flex-wrap u-flex-between u-flex-items-center">
								<label class="u-flex u-m-t-10 w_40" v-for="(item, index) in radiolist7"
									:key="item.name">
									<view>
										<radio :value="item.name" color='#DAAF7F' :checked="index === current6" />
									</view>
									<view>{{item.name}}</view>
								</label>
							</radio-group>
						</view>
					</u-form-item>
					<u-form-item label="出租时长:" :required="true">
						<view>
							<radio-group @change="radioChange7"
								class="u-flex u-flex-wrap u-flex-between u-flex-items-center">
								<label class="u-flex u-m-t-10 w_40" v-for="(item, index) in radiolist3"
									:key="item.name">
									<view>
										<radio :value="item.name" color='#DAAF7F' :checked="index === current7" />
									</view>
									<view>{{item.name}}</view>
								</label>
							</radio-group>
						</view>
					</u-form-item>
					<u-form-item label="如何看房:" :required="true">
						<view>
							<radio-group @change="radioChange8"
								class="u-flex u-flex-wrap u-flex-between u-flex-items-center">
								<label class="u-flex u-m-t-10 w_40" v-for="(item, index) in radiolist9"
									:key="item.name">
									<view>
										<radio :value="item.name" color='#DAAF7F' :checked="index === current8" />
									</view>
									<view>{{item.name}}</view>
								</label>
							</radio-group>
						</view>
					</u-form-item>

				</u--form>
				<!-- 地图 -->
				<map style="width:600rpx; height: 250rpx;margin:30rpx auto;"
					:latitude=" fromData.lat ? fromData.lat :latitude"
					:longitude=" fromData.lon ? fromData.lon :longitude" @tap="tap" :enable-zoom='false'
					:enable-scroll='false' scale='14'></map>
				<view class="tijiao" @click="submit">下一步</view>
			</view>
		</view>
		<!-- 房屋押金 -->
		<u-picker :show="shows" :columns="yajin" @cancel='shows = false' @confirm='confirmy' @close='close'
			:closeOnClickOverlay='true'></u-picker>
		<!-- 房屋朝向 -->
		<u-picker :show="show" :columns="columns" @cancel='show = false' @confirm='confirm' @close='close'
			:closeOnClickOverlay='true'></u-picker>
		<!-- 房屋地址 -->
		<!-- 电梯 -->
		<u-picker :show="showa" :columns="columnsa" @cancel='showa = false' @confirm='confirma' @close='close'
			:closeOnClickOverlay='true'></u-picker>
		<!-- 省市区 -->
		<u-picker :show="showArea" :columns="sheng" @cancel='showArea = false' keyName="name" @confirm='confirmArea'
			@close='close' :closeOnClickOverlay='true'></u-picker>
	</view>
</template>

<script>
	import uploadImage from '@/js_sdk/yushijie-ossutil/ossutil/uploadFile.js';
	export default {
		data() {
			return {
				showArea: false,
				fileList1: [],
				show: false,
				shows: false,
				yajin: [
					[
						'押一付一',
						'押一付二',
						'押二付一',
						'押三付一'
					]
				],
				columns: [
					[
						'东',
						'南',
						'西',
						'北'
					]
				],
				showa: false,
				columnsa: [
					[
						'无电梯',
						'一部',
						'两部',
						'三部',
						'四部'
					]
				],
				showb: false,
				showc: false,
				showSex: false,
				fromData: {
					pics: [],
					properties_name: '', //楼盘名称
					floor: '', //居住楼层
					roomnumber: '', //居住房号
					price: '', //出租价格
					area: '', //出租面积
					orientation: '', //房屋朝向
					paytype: '', //房屋押金
					bedroom: '', //房屋户型(室)
					room: '', //房屋户型(厅)
					toilet: '', //房屋户型(卫)
					balcony: '', //房屋户型(厨房)
					province: '', //省
					city: '', //房屋地址城市
					areaname: '', //房屋地址区
					images: [], //图片
					elevator: '', //电梯几部
					style: '', //装修
					situation: '', //状态
					lookroom: '', //看房
					facilities: '', // 贷款情况
					is_cook: '', //可否煮饭
					is_child: '',
					is_pets: '', // 唯一
					roomnature: '', //性质
					lat: '',
					lon: '',
					address: '',
					properties_id: '',
					shiming_id: ''
				},
				elevator: null,
				radiolist1: [{
						name: '毛坯',
						disabled: false
					},
					{
						name: '豪华装修',
						disabled: false
					},
					{
						name: '精简装修',
						disabled: false
					}
				],
				radiolist2: [{
						name: '自行居住',
						disabled: false
					},
					{
						name: '租户居住',
						disabled: false
					},
					{
						name: '房屋空置',
						disabled: false
					}
				],
				radiolist3: [{
						name: '1年内',
						disabled: false
					},
					{
						name: '1年-3年',
						disabled: false
					},
					{
						name: '3年以上',
						disabled: false
					}
				],
				radiolist4: [{
						name: '床',
						disabled: false
					},
					{
						name: '空调',
						disabled: false
					},
					{
						name: '衣柜',
						disabled: false
					},
					{
						name: '热水器',
						disabled: false
					},
					{
						name: '天然气',
						disabled: false
					},
					{
						name: '电视',
						disabled: false
					},
					{
						name: '冰箱',
						disabled: false
					},
					{
						name: '暖气',
						disabled: false
					},
					{
						name: '洗衣机',
						disabled: false
					},
					{
						name: '宽带',
						disabled: false
					}
				],
				radiolist5: [{
						name: '可以',
						disabled: false
					},
					{
						name: '不可以',
						disabled: false
					}
				],
				radiolist6: [{
						name: '可以',
						disabled: false
					},
					{
						name: '不可以',
						disabled: false
					}
				],
				radiolist7: [{
						name: '可以',
						disabled: false
					},
					{
						name: '不可以',
						disabled: false
					}
				],
				radiolist8: [{
						name: '商品房',
						disabled: false
					},
					{
						name: '别墅',
						disabled: false
					},
					{
						name: '公寓',
						disabled: false
					},
					{
						name: '商铺',
						disabled: false
					},
					{
						name: '写字楼',
						disabled: false
					}
				],
				radiolist9: [{
						name: '随时可看',
						disabled: false
					},
					{
						name: '提前24小时',
						disabled: false
					}
				],
				radiovalue4: '',
				radiovalue5: '',
				latitude: null,
				longitude: null,
				current0: null,
				current1: null,
				current2: null,
				current3: null,
				current4: null,
				current5: null,
				current6: null,
				current7: null,
				current8: null,
				images: [], // 图片
				loading_show_status: false,
				fangzi_id: null,
				obj: {},
				sheng: [],
				key: 'province',
				loupanList: [],
				distinguish: 1,
				guidance_price: '',
				loupanShow: false,
				type: 0,
				citydata: [],
				ida: null,
				rules: {
					properties_name: [{
						required: true,
						message: '请输入楼盘名称',
						trigger: ['blur', 'change']
					}],
					orientation: [{
						required: true,
						message: '请选择房屋朝向',
						trigger: ['blur', 'change']
					}],
					floor: [{
						validator: (rule, value, callback) => {
							return /^\d+$/.test(value);
						},
						message: '请输入居住楼层',
						trigger: ['blur', 'change']
					}],
					roomnumber: [{
						validator: (rule, value, callback) => {
							return /^\d+$/.test(value);
						},
						message: '请输入居住楼层的房号',
						trigger: ['blur', 'change']
					}],
					price: [{
						validator: (rule, value, callback) => {
							return /^\d+$/.test(value);
						},
						message: '请输入出租价格',
						trigger: ['blur', 'change']
					}],
					area: [{
						required: true,
						message: '请输入出租面积',
						trigger: ['blur', 'change']
					}],
					province: [{
						required: true,
						message: '请选择房屋地址',
						trigger: ['blur', 'change']
					}]
				},
				shiming_id: null,
				jiekou: 0,
			};
		},
		watch: {
			'fromData.properties_name': {
				handler(newName, oldName) {
					if (newName.length < oldName.length) {
						this.distinguish = 1;
						this.fromData.lat = '';
						this.fromData.lon = '';
					}
				},
				deep: true
			}
		},
		onReady() {
			this.$refs.uForm.setRules(this.rules);
		},
		async onLoad(e) {
			console.log(e, '干哈呀')
			// #ifdef MP-WEIXIN
			uni.hideShareMenu();
			// #endif
			if (e.type) {
				this.type = +e.type;
			}
			if (e.item) {
				let fen = JSON.parse(e.item);
				this.fromData.fangchanzheng_id = fen.FZ;
				this.fromData.shiming_id = fen.ZM;
				this.fromData.shiming_back_id = fen.FM;
			}

			let that = this;
			uni.getLocation({
				type: 'gcj02',
				success: function(res) {
					that.latitude = res.latitude;
					that.longitude = res.longitude;
				}
			});
			await this.getsheng();

			if (e.id) {
				uni.setNavigationBarTitle({
					title: '修改房子资料'
				});
				this.jiekou = +e.id;
				let res = await this.require('getAouse', {
					id: +e.id
				});
				if (res) {
					this.fromData = res;
					this.fromData.balcony = res.balcony;
					this.fromData.price = res.price / 1;
					this.distinguish = 2;
					this.loupanList.map((p, i) => {
						if (p.id == res.fczj_properties_id) {
							this.guidance_price = p.guidance_price;
						}
					})
					this.fromData.lat = +res.lat;
					this.fromData.lon = +res.lon;
					this.images = [...res.images.split(',')];
					this.current0 = res.style == '毛坯' ? 0 : res.style == '豪华装修' ? 1 : 2;
					this.current1 = res.situation == '自行居住' ? 0 : res.situation == '租户居住' ? 1 : 2;
					this.current2 = res.lookroom == '随时看房' ? 0 : 1;
					this.current4 = res.cardyear5_switch == 1 ? 0 : null;
					this.current5 = res.cardyear2_switch == 1 ? 0 : null;
					this.current6 = res.only_switch;
					this.current7 = res.duration == '1年内' ? 0 : res.duration == '1年-3年' ? 1 : res.duration ==
						'3年以上' ? 2 : '';
					this.fromData.elevator = res.elevator == 0 ? '无电梯' : res.elevator == 1 ? '一部' : res.elevator == 2 ?
						'两部' : res.elevator == 3 ? '三部' : '四部';
					this.elevator = res.elevator;
					let arr2 = []
					for (var i = 0; i < this.radiolist4.length; i++) {
						for (var j = 0; j < res.facilities.length; j++) {
							if (this.radiolist4[i].name == res.facilities[j].name) {
								this.radiolist4[i].disabled = true;
								arr2.push({
									name: res.facilities[j].name
								})
							}
						}
					}
					this.current3 = arr2;
					this.current6 = res.is_pets == '可以' ? 0 : 1; //可否携宠物
					this.current5 = res.is_child == '可以' ? 0 : 1; //可否住小孩
					this.current4 = res.is_cook == '可以' ? 0 : 1; //可否煮饭
					this.current8 = res.lookroom == '随时可看' ? 0 : 1
				}
			}
		},
		methods: {
			// 获取全部省市区
			async getsheng() {
				let res = await this.require('cityall');
				if (res) {
					this.citydata = res;
				}
			},
			tap() {
				let that = this;
				if (this.fromData.lat && this.fromData.address) return;
				uni.chooseLocation({
					success: function(res) {
						that.fromData.lat = res.latitude;
						that.fromData.lon = res.longitude;
						that.fromData.address = res.address;
					}
				})
			},
			getmieng(item, index) {
				this.loupanShow = false;
				this.distinguish = 2;
				this.fromData.properties_name = item.name;
				this.fromData.lat = item.lat;
				this.fromData.lon = item.lon;
				this.fromData.address = item.address;
				this.fromData.properties_id = item.id
				this.ida = item.id;
				this.guidance_price = item.guidance_price;
			},
			async search() {
				if (this.distinguish === 2) return;
				if (this.fromData.properties_name.length > 0) {
					this.loupanShow = true;
				} else {
					this.loupanShow = false;
					this.fromData.lat = '';
					this.fromData.lon = '';
					this.guidance_price = '';
					this.fromData.properties_name = '';
				}

				let res = await this.require('propertieslist', {
					keywords: this.fromData.properties_name,
					p: this.params.p,
					pnum: this.pnum,
					loupanleixing: '二手房'
				});
				if (res) {
					this.loupanList = res;
				} else {
					this.loupanList = [];
					this.distinguish = 2;
				}
			},
			async pick(key) {
				this.key = key;
				await this.getsheng();
				switch (key) {
					case 'province':
						this.sheng = [this.citydata];
						break;
					case 'city':
						if (!this.fromData.province) {
							return this.$u.toast('请依次选择省市区')
						}
						this.sheng = [this.citydata[this.obj.province_idx].child]
						break;
					case 'areaname':
						if (!this.fromData.city) {
							return this.$u.toast('请依次选择省市区')
						}
						this.sheng = [this.citydata[this.obj.province_idx].child[this.obj.city_idx].child]
						break;
					default:
						break;
				}
				this.showArea = true;
			},
			radioChange0(evt) {
				for (let i = 0; i < this.radiolist1.length; i++) {
					if (this.radiolist1[i].name === evt.detail.value) {
						this.current0 = i;
						break;
					}
				}
			},
			radioChange1(evt) {
				for (let i = 0; i < this.radiolist2.length; i++) {
					if (this.radiolist2[i].name === evt.detail.value) {
						this.current1 = i;
						break;
					}
				}
			},
			radioChange2(evt) {
				for (let i = 0; i < this.radiolist8.length; i++) {
					if (this.radiolist8[i].name === evt.detail.value) {
						this.current2 = i;
						break;
					}
				}
			},
			radioChange3(evt) {
				let arr1 = []
				console.log(evt, '???????');
				for (let var1 in evt) {
					if (evt[var1]) {
						arr1.push({
							name: evt[var1]
						})
					}
				}
				this.current3 = arr1
			},
			radioChange4(evt) {
				if (this.current4 === 0) {
					this.current5 = null;
				}
				for (let i = 0; i < this.radiolist5.length; i++) {
					if (this.radiolist5[i].name === evt.detail.value) {
						this.current4 = i;
						this.radiovalue4 = evt.detail.value;
						break;
					}
				}
			},
			radioChange5(evt) {
				if (this.current5 === 1) this.current4 = null;
				for (let i = 0; i < this.radiolist6.length; i++) {
					if (this.radiolist6[i].name === evt.detail.value) {
						this.current5 = i;
						this.radiovalue5 = evt.detail.value;
						break;
					}
				}
			},
			radioChange6(evt) {
				for (let i = 0; i < this.radiolist7.length; i++) {
					if (this.radiolist7[i].name === evt.detail.value) {
						this.current6 = i;
						break;
					}
				}
			},
			radioChange7(evt) {
				for (let i = 0; i < this.radiolist3.length; i++) {
					if (this.radiolist3[i].name === evt.detail.value) {
						this.current7 = i;
						break;
					}
				}
			},
			radioChange8(evt) {
				for (let i = 0; i < this.radiolist9.length; i++) {
					if (this.radiolist9[i].name === evt.detail.value) {
						this.current8 = i;
						break;
					}
				}
			},

			async submit() {
				if (!await this.getMobile()) {
					return;
				}
				this.$refs.uForm.validate().then(res => {
					this.upfrom();
				}).catch(errors => {})
			},
			async upfrom() {
				let from = uni.$u.deepClone(this.fromData);

				if (this.loupanList.length) {
					this.loupanList.map((p, i) => {
						if (p.id == this.ida) {
							from.lat = p.lat;
							from.lon = p.lon;
							from.address = p.address;
						}
					})
				} else if (!from.lat) {
					uni.$u.toast('请打开地图选择楼房位置');
					return
				}
				if (!this.images.length) {
					uni.$u.toast('请上传房屋照片');
					return
				} else if (this.images.length < 5) {
					uni.$u.toast('请上传至少五张图片');
					return;
				} else if (this.current0 == null) {
					uni.$u.toast('请选择装修情况');
					return;
				} else if (this.current1 == null) {
					uni.$u.toast('请选择房屋状态');
					return;
				} else if (this.current2 == null) {
					uni.$u.toast('请选择出租时长');
					return;
				} else if (this.current3 == null) {
					uni.$u.toast('请选择配套设施');
					return;
				} else if (this.current6 == null) {
					uni.$u.toast('请选择可否携宠物');
					return;
				} else if (this.current8 == null) {
					uni.$u.toast('请选择如何看房');
					return;
				} else if (this.elevator == null) {
					uni.$u.toast('请选择电梯情况');
					return;
				}
				from.images = this.images.join(',');
				from.style = this.current0 != null ? this.radiolist1[this.current0].name : ''; //是否带装修
				from.situation = this.current1 != null ? this.radiolist2[this.current1].name : ''; //房屋状态
				from.duration = this.current7 != null ? this.radiolist3[this.current7].name : ''; //出租时长
				from.lookroom = this.current8 != null ? this.radiolist9[this.current8].name : ''; //如何看房
				from.facilities = this.current3; //是否带家具(配套设施)
				from.is_cook = this.radiovalue4 == 0 ? 1 : 0; //可否煮饭
				from.is_child = this.radiovalue5 == 0 ? 1 : 0; //可否住小孩
				from.is_pets = this.current6 === 0 ? 1 : 0; //可否携宠物
				from.roomnature = this.current2 != null ? this.radiolist8[this.current2].name : ''; //房屋性质
				from.elevator = this.elevator; //是否有电梯
				from.lat = +from.lat;
				from.lon = +from.lon;
				// from.fangchanzheng_id = this.fangzi_id;
				// from.shiming_id = this.shiming_id.ZM;
				
				let jie = null;
				if (this.jiekou == 0) {
					jie = 'getAddhouse';
					console.log("上传资料")
				} else {
					jie = 'revisetowhouse';
					from.id = from.id; // 房子id
					from.properties_id = from.fczj_properties_id; // 楼盘id
					from.properties_name = from.properties_name; //楼盘名称
					console.log('修改资料')
				}
				let res22 = await this.require(jie, from);
				if (res22) {
					this.nextNav('/pages/mine/chuzu')
				}


			},
			confirm(e) {
				this.fromData.orientation = e.value[0];
				this.show = false;
			},
			confirmy(e) {
				this.fromData.paytype = e.value[0];
				this.shows = false;
			},
			confirma(e) {
				this.fromData.elevator = e.value[0];
				this.elevator = e.indexs[0]
				this.showa = false;
			},
			confirmArea(e) {
				this.showArea = false;
				this.obj[this.key] = e.value[0].id;
				this.obj[this.key + '_idx'] = e.indexs[0];
				this.fromData[this.key] = e.value[0].name;
			},
			close() {
				this.showa = false;
				this.show = false;
				this.shows = false;
			},
			radioChange(n) {
				console.log('radioChange', n);
			},
			//上传图片
			getup() {
				const that = this;
				that.loading_show_status = true;
				uni.chooseImage({
					sourceType: ['album', 'camera'],
					success: async res => {
						for (let i = 0; i < res.tempFilePaths.length; i++) {
							uni.showLoading({
								mask: true
							});
							uploadImage(
								res.tempFilePaths[i],
								'roomuploads/' + uni.$u.timeFormat(new Date(), 'yyyymmdd'),
								result => {
									that.images.push(result);
									uni.hideLoading();
								},
								result => {
									//这里写上传失败的代码
									uni.hideLoading();
								}
							);
						}
					},
					complete() {
						that.operation_view_show = false;
						that.loading_show_status = false;
						that.scroll_view_height = that.scrollHeight;
					}
				});
			},
			getde(index) {
				this.images.splice(index, 1);
			}
		}
	}
</script>


<style lang="scss" scoped>
	.m-bg-c {
		background: linear-gradient(#0e5642, #0E5642 200rpx, #F2F2F2 200rpx, #F2F2F2 100%);
		padding: 30rpx;
	}

	.boxhuxing {
		width: 68rpx;
		height: 64rpx;
		background-color: #eee;
		border-radius: 5rpx;
	}

	.boxinput {
		top: 16px;
		right: 0;
		left: 0;
		text-align: center;
		border-radius: 10rpx;
	}

	.boxinput-y {
		overflow-y: auto;
		height: 300rpx;
	}

	.boximg {
		width: 188rpx;
		height: 188rpx;
		position: relative;
		z-index: 1;
	}

	.w_40 {
		width: 45% !important;
	}

	.boxdizhi {
		width: 120rpx;
		height: 64rpx;
		overflow-x: auto;
		line-height: 64rpx;
		text-align: center;
		background-color: #eee;
		border-radius: 4rpx;
	}

	.ce1 {
		color: #CECCCC;
	}

	.iconde {
		position: absolute;
		top: -10rpx;
		right: -10rpx;
		z-index: 99;
	}

	.boxup {
		width: 192rpx;
		height: 192rpx;
		background-color: #f8f8f8;
		color: #ddd;
	}

	.input {
		width: 450rpx !important;
	}

	.v-input {
		width: 200rpx !important;
		display: flex;
		align-items: center;
	}

	.y-input {
		width: 200rpx !important;
		display: flex;
		align-items: center;
	}

	.s-input {
		width: 100rpx !important;
		display: flex;
		align-items: center;
		margin-left: 15rpx;
	}

	.t-input {
		width: 100rpx !important;
		display: flex;
		align-items: center;
	}

	.m-c-9 {
		color: #C0C0C0;
	}

	.tijiao {
		width: 300rpx;
		height: 80rpx;
		margin: auto;
		background-color: #0E5543;
		border-radius: 20rpx;
		color: #FFFFFF;

		display: flex;
		justify-content: center;
		align-items: center;
	}
</style>
